/**
 * @Author: hl
 * @Date: 2019/8/16
 * @Last Modified by: hl
 * @Last Modified time:
 */

import axios from '@/api/fetch';
import * as types from './types';
import SERVER from '@/api/server';
import dictCode from '@/utils/dictCode';
import { getCompanyId, getAppId } from '@/assets/js/auth';

// 保存
export const saveOrder = params => axios.post(`${SERVER.DMSCLOUD_PART}/stockmanage/partinners/save`, params);
// 查询单据明细
export const showDetailRequest = inId => axios.get(`${SERVER.DMSCLOUD_PART}/stockmanage/partinners/detail/${inId}`, {});
// 查询单据明细区分模块
export const showDetailRequestByType = params => axios.get(`${SERVER.DMSCLOUD_PART}/stockmanage/partinners/detail/${params.id}`, { params });
// 查询需要选择的单据
export const getOrderData = params => axios.get(`${SERVER.DMSCLOUD_PART}/stockmanage/partinners/searchInnerPart`, { params });
// 作废单据
export const deleteOrder = innerID => axios.delete(`${SERVER.DMSCLOUD_PART}/stockmanage/partinners/deletes/${innerID}`, {});
// 查询备件出库是否会导致负库存
export const queryPartIfBelowZero = params => axios.post(`${SERVER.DMSCLOUD_PART}/stockmanage/partinners/queryPartIfBelowZero`, params);
// 单据入账
export const stockIn = (innerNo, str) => axios.post(`${SERVER.DMSCLOUD_PART}/stockmanage/partinners/yes/${innerNo}/${str}`, {});
// 单据审核
export const auditOrder = innerID => axios.post(`${SERVER.DMSCLOUD_PART}/stockmanage/partinners/audit/${innerID}`, {});
//
export const getStorage = params => axios.get(`${SERVER.DMSCLOUD_PART}/basedata/partStocks/findUserControlStorageCode`, {});
// 获取打印数据接口
export const printData = (id, params) => axios.get(`${SERVER.DMSCLOUD_PART}/stockmanage/partinners/queryPrintInnerData/${id}`, { params });

export const getOrgByOrgType = params => {
  params.companyId = getCompanyId();
  params.appId = getAppId();
  return axios.get(`${SERVER.DMSCLOUD_BASEDATA}/org/getOrgByOrgType`, { params });
};
// 根据部门获取人员
export const getUserByOrgId = params => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/positions/getUserByOrgIdNew`, { params });

// 领料人
export const getLingLiaoRenSelect = params => {
  // return testDict;
  return axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/users/getUserListByRole?role=` + dictCode.MATERIAL_AVAILABLE + '&companyId=' + getCompanyId(), { params });
};
